<?php
namespace Admin\Controller;
use Think\Controller;
class MessageController extends Controller
{
    public function index()
    {
        $this->display();
       
    }

    /*反馈信息*/
    public function messagelist(){
        $message = M('message');
        $messagelist = $message->order("mid asc")->field('mid,clubname,m_info,m_time')->select();

        for($index=0;$index<count($messagelist);$index++)
        {
            $messageist[$index]['number']=$index+1;
        }

        $this->assign('messagelist',$messagelist);
        $this->display();
    }

     public function delmessage()
    {
        $mid=I('mid');
        $messagesModel = M('message');
        $message=$messagesModel->where("mid=$mid")->find();
        // unlink(realpath("./Public/Uploads/logo/".$user["photo"]));
        if($messagesModel->delete($mid)) {
            $this->success('删除成功');
        }
        else {
            $this->error('删除失败');
        }
           
    }
    public function addmessage(){
        $this->display();
    }  
        public function newmessage(){
        $m = M("message");
        $m->clubname=I('post.clubname');
        $m->m_info=I('post.m_info');
        $m->m_time=I('post.m_time');
        $m->clubid = $_SESSION['clubid'];
        if(false!=$m->add()){
            $this->redirect('Message/messagelist','',2,'添加成功，页面跳转中...');
        }else{
            $this->error("添加失败！");
        }
    }
}